function geturlpathname() {
	var url = document.location.toString();
	var arrUrl = url.split("//");
	var start = arrUrl[1].indexOf("/");
	var relUrl = arrUrl[1].substring(start);
	if(relUrl.indexOf("?") != -1){
		relUrl = relUrl.split("?")[0];
	}
	return relUrl;
}
function confirmurl(url,message) {
	if (typeof pc_hash == 'string') url += (url.indexOf('?') > -1 ? '&': '?') + 'pc_hash=' + pc_hash;
	Dialog.confirm(message,function() {
		redirect(url);
	});
}
function redirect(url) {
	location.href = url;
}
function topinyin(name, from, url) {
	var val = $("#" + from).val();
	if ($("#" + name).val()) {
		return false
	}
	$.get(url+'&name='+val+'&rand='+Math.random(), function(data){
		$('#'+name).val(data);
	});
}
//滚动条
$(function(){
	$(":text").addClass('input-text');
})

/**
 * 全选checkbox,注意：标识checkbox id固定为为check_box
 * @param string name 列表check名称,如 uid[]
 */
function selectall(name) {
	if ($("#check_box").attr("checked")=='checked') {
		$("input[name='"+name+"']").each(function() {
  			$(this).attr("checked","checked");
			$(this).parents('tr').css("background-color","#eef1f5");
		});
	} else {
		$("input[name='"+name+"']").each(function() {
  			$(this).removeAttr("checked");
			$(this).parents('tr').removeAttr("style");
		});
	}
}
function openwinx(url,name,w,h) {
	if(!w) w='100%';
	if(!h) h='100%';
	if (typeof pc_hash == 'string') url += (url.indexOf('?') > -1 ? '&': '?') + 'pc_hash=' + pc_hash;
	var diag = new Dialog({
		id:'content_id',
		title:name,
		url:geturlpathname()+url,
		width:w,
		height:h,
		modal:true
	});
	diag.cancelText = '关闭(X)';
	diag.onCancel=function() {
		$DW.close();
	};
	diag.show();
}
function contentopen(url,name,w,h) {
	if(!w) w='100%';
	if(!h) h='100%';
	if (typeof pc_hash == 'string') url += (url.indexOf('?') > -1 ? '&': '?') + 'pc_hash=' + pc_hash;
	var diag = new Dialog({
		id:'content_id',
		title:name,
		url:geturlpathname()+url,
		width:w,
		height:h,
		modal:true
	});
	diag.addButton('dosubmit','保存后自动关闭',function(){
		//var body = diag.innerFrame.contentWindow.document;
		//$(body).find('#myform').serialize()
		var form = $DW.$('#dosubmit');
		if(form.length > 0) {
			form.click();
		} else {
			parent.right.location.reload();
			diag.close();
		}
		return false;
	},0,1);
	diag.okText = '保存并继续发表';
	diag.onOk = function(){
		var form = $DW.$('#dosubmit_continue');
		if(form.length > 0) {
			form.click();
		} else {
			parent.right.location.reload();
			diag.close();
		}
		return false;
	};
	diag.cancelText = '关闭(X)';
	diag.onCancel=function(){
		var form = $DW.$('#close');
		if(form.length > 0) {
			form.click();
		} else {
			parent.right.location.reload();
			$DW.close();
		}
		return false;
	};
	diag.onClose=function(){
		parent.right.location.reload();
		$DW.close();
	};
	diag.show();
}
//弹出对话框
function artdialog(id,url,title,w,h) {
	if (typeof pc_hash == 'string') url += (url.indexOf('?') > -1 ? '&': '?') + 'pc_hash=' + pc_hash;
	if(!w) w=700;
	if(!h) h=500;
	var diag = new Dialog({
		id:id,
		title:title,
		url:geturlpathname()+url,
		width:w,
		height:h,
		modal:true
	});
	diag.onOk = function(){
		var form = $DW.$('#dosubmit');
		form.click();
		return false;
	};
	diag.onCancel=function() {
		$DW.close();
	};
	diag.show();
}
//弹出对话框
function omnipotent(id,linkurl,title,close_type,w,h) {
	if (typeof pc_hash == 'string') linkurl += (linkurl.indexOf('?') > -1 ? '&': '?') + 'pc_hash=' + pc_hash;
	if(!w) w=700;
	if(!h) h=500;
	var diag = new Dialog({
		id:id,
		title:title,
		url:geturlpathname()+linkurl,
		width:w,
		height:h,
		modal:true
	});
	diag.onOk = function(){
		if(close_type==1) {
			diag.close();
		} else {
			var form = $DW.$('#dosubmit');
			form.click();
		}
		return false;
	};
	diag.onCancel=function() {
		$DW.close();
	};
	diag.show();
}